package com.renwei.yunlong.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.renwei.yunlong.R;
import com.renwei.yunlong.bean.ServerChooseServiceFloderBean;
import com.zyf.fwms.commonlibrary.base.baseadapter.BaseRecyclerViewAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Project :  yunna.
 * Package name: com.renwei.yunlong.adapter
 * Created by :  Benjamin.
 * Created time: 2018/1/19 14:04
 * Changed by :  Benjamin.
 * Changed time: 2018/1/19 14:04
 * Class description:
 */

public class ServerServiceFloderListAdapter extends BaseRecyclerViewAdapter<ServerChooseServiceFloderBean.RowsBean> {

    public ServerServiceFloderListAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ServerServiceFloderListAdapter.PHoloder(inflater.inflate(R.layout.item_text, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ServerServiceFloderListAdapter.PHoloder pHoloder = (ServerServiceFloderListAdapter.PHoloder) holder;
        ServerChooseServiceFloderBean.RowsBean item = getItem(position);
        if (!TextUtils.isEmpty(item.getDetailName())) {
            pHoloder.tv.setText(item.getDetailName());
        }
        if (!TextUtils.isEmpty(item.getServicesDirectoryName())) {
            pHoloder.tv.setText(item.getServicesDirectoryName());
        }
        pHoloder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemClickLitener.onItemClick(v, position);
            }
        });
    }

    class PHoloder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv)
        TextView tv;

        public PHoloder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
